package com.hichina.client.util;


import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Properties;

/**
 * Created by IntelliJ IDEA.
 * User: zigang.wang
 * Date: 12-2-28
 * Time: 下午6:31
 * To change this template use File | Settings | File Templates.
 */
public class Setting implements Serializable {
    private static final Log log = LogFactory.getLog(Setting.class);
    public static Properties SETTINGS;
    static {
        init();
    }

    private static void init() {

        SETTINGS = new Properties();
        InputStream stream = Setting.class.getClassLoader().getResourceAsStream("setting.properties");
        try {
            SETTINGS.load(stream);
        } catch (IOException e) {
            log.error("初始化配置失败！", e);
        } finally {
            IOUtils.closeQuietly(stream);
        }

    }

    public static String getSetting(String key) {
        return SETTINGS.getProperty(key);
    }

}
